package com.travel.admin.constants;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public enum Platform {
	SYS("sys","管理"),
	WEBAPP("webapp","手机网站"),
	ANDROID("android","安卓"),
	IOS("ios","苹果"),
	PC("pc","网站"),
	ORG_DATA_BANK_MARKET("data_bank_market","第三方数藏行情机构");
	public static final Map<String, Device> DEVIVCE = new HashMap<String, Device>();
	static {
		DEVIVCE.put(SYS.code, Device.PC);
		DEVIVCE.put(WEBAPP.code, Device.MD);
		DEVIVCE.put(ANDROID.code, Device.MD);
		DEVIVCE.put(IOS.code, Device.MD);
		DEVIVCE.put(PC.code, Device.PC);
	}

	public static final Map<String, TimeUnit> TOKEN_EXPIRE_UNIT = new HashMap<String, TimeUnit>();
	static {
		TOKEN_EXPIRE_UNIT.put(SYS.code, TimeUnit.HOURS);
		TOKEN_EXPIRE_UNIT.put(WEBAPP.code, TimeUnit.HOURS);
		TOKEN_EXPIRE_UNIT.put(ANDROID.code, TimeUnit.HOURS);
		TOKEN_EXPIRE_UNIT.put(IOS.code, TimeUnit.HOURS);
		TOKEN_EXPIRE_UNIT.put(PC.code, TimeUnit.HOURS);
	}

	public static final Map<String, Long> TOKEN_EXPIRE = new HashMap<String, Long>();
	static {
		TOKEN_EXPIRE.put(SYS.code, 10000L);
		TOKEN_EXPIRE.put(WEBAPP.code, 10000L);
		TOKEN_EXPIRE.put(ANDROID.code, 10000L);
		TOKEN_EXPIRE.put(IOS.code, 10000L);
		TOKEN_EXPIRE.put(PC.code, 10000L);
	}
	
	private String code;
	private String name;
	private Platform(String code,String name){
		this.code = code;
		this.name = name;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public static String getCode(String name){
		for (Platform gender : Platform.values()) {
            if (gender.getName().equals(name)) {
                return gender.code;
            }
        }
		return null;
	}
	public static String getName(String code){
		for (Platform gender : Platform.values()) {
            if (gender.getCode().equals(code)) {
                return gender.name;
            }
        }
		return null;
	}
	public static Platform get(String code){
		for (Platform value : Platform.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
		return null;
	}
}
